# Contributor: Jordan Christiansen <xordspar0@gmail.com>
# Maintainer: Jordan Christiansen <xordspar0@gmail.com>
pkgname=sanoid
pkgver=2.2.0
pkgrel=0
pkgdesc="Policy-driven snapshot management and replication tools"
url="https://github.com/jimsalterjrs/sanoid"
arch="noarch"
license="GPL-3.0-only"
depends="procps perl-config-inifiles perl-capture-tiny"
_depends_syncoid="procps perl-capture-tiny pv gzip lzop mbuffer"
checkdepends="bash"
subpackages="syncoid"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/jimsalterjrs/sanoid/archive/v$pkgver.tar.gz
	$pkgname.cron
	"

check() {
	tests/run-tests.sh
}

package() {
	install -Dm775 sanoid "$pkgdir"/usr/bin/sanoid
	install -Dm775 findoid "$pkgdir"/usr/bin/findoid

	install -Dm644 sanoid.conf "$pkgdir"/etc/sanoid/sanoid.conf
	install -Dm644 sanoid.defaults.conf "$pkgdir"/etc/sanoid/sanoid.defaults.conf

	install -Dm755 "$srcdir"/sanoid.cron "$pkgdir"/etc/periodic/15min/sanoid
}

syncoid() {
	depends="$_depends_syncoid"
	install -Dm775 "$builddir"/syncoid "$subpkgdir"/usr/bin/syncoid
}

sha512sums="
293c31f2da80d698987c7f06314bf6e62a54011e4028b2aa8e70d482e7757bf8ae89efe7413b8f88072bac064710ca0756650e5b6f9827a5ff50a97fd72e86ad  sanoid-2.2.0.tar.gz
ba7d9ec8978fe12de44918a94821fa73dd1e4839cf6add587b061a153a58169f936bfe6da281144ceb01d799279ba82a738f39eaab05d6901b949e04d9c5217a  sanoid.cron
"
